﻿/*
 * 作者：唐桥
 * 功能描述：实现Sql Server数据库的数据添加（原来是对Access的查询）
 * 时间：2018-1-18
 * 修改人：唐桥
 * 修改时间：2018-1-18 19:30
 *
 */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DataBusiness;
using Entity;
using UI.BasicData;

namespace UI.BasicData
{
    public partial class frmLithologicSectionAdd : DevExpress.XtraEditors.XtraForm
    {
        private readonly object gridControl1;
        public int returnFlag = 0;
        public frmLithologicSectionAdd()
        {
            InitializeComponent();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
           
            Close();
        }
        /// <summary>添加岩性剖面信息到数据库 </summary>
        /// <param name="t">岩性剖面信息对象</param>
        /// <returns>返回所影响的数据行数</returns>
        private void btnSure_Click(object sender, EventArgs e)
        {
            tb_LithologicSectionModel t = new tb_LithologicSectionModel(int.Parse(this.txtID.Text.ToString()), this.txtWellNO.Text,
                int.Parse(this.txtHorizon.Text.ToString()), this.cbBMainLithology.Text, decimal.Parse(this.txtWellDepth.Text.ToString()),
                  decimal.Parse(this.txtLiThickness.Text.ToString()), decimal.Parse(this.txtStartLocation.Text.ToString()), decimal.Parse(this.txtEndLocation.Text.ToString()),
                Guid.NewGuid(), dTPInputDate.Value);
            if (string.IsNullOrEmpty(this.txtWellNO.Text) || string.IsNullOrEmpty(this.cbBMainLithology.Text) ||
                string.IsNullOrEmpty(this.txtWellDepth.Text) || string.IsNullOrEmpty(this.txtLiThickness.Text) ||
                string.IsNullOrEmpty(this.txtStartLocation.Text) || string.IsNullOrEmpty(this.txtEndLocation.Text) ||
                string.IsNullOrEmpty(this.txtUserID.Text))
            {
                MessageBox.Show("添加的信息不完整！");
            }
            else
            {
               
                LithologicSectionBLL.InsertLithologicSection(t);
                returnFlag = 1;
                DialogResult dr = MessageBox.Show("添加成功,是否继续添加?", "对话框标题", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (dr == DialogResult.OK)
                {
                    
                }
                else
                {

                    Close();
                }
                
            }
        }
    }
}